package monitor.mobie.hdy.im.service;

import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;


public class TestService  extends Service {

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    @Override
    public void onCreate() {
        System.out.println("monitor service onCreate");
        super.onCreate();
        init();
    }
    /**
     * 初始化操作
     */
    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    public void init() {
    }

    @Override
    public void onDestroy() {
        System.out.println("monitor service onDestroy");
        //进行自动重启
        Intent intent = new Intent(TestService.this, MonitorService.class);
        //重新开启服务
        startService(intent);
        stopForeground(true);
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }

}
